<template>
  <div class="tab-control">
    <div
      v-for="(title, index) in titles"
      :key="title"
      class="tab-control-item"
      :class="{ active: itemIndex == index ? true : false }"
      @click="isshow(index)"
    >
      <span>{{ title }}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      itemIndex: 0,
    };
  },
  emits: ["tabclick"],
  props: ["titles"],
  methods: {
    isshow(index) {
      this.itemIndex = index;
      this.$emit("tabclick", index);
    },
  },
};
</script>

<style scoped>
.tab-control {
  display: flex;
  font-size: 14px;
  background-color: rgb(255, 255, 255);
}
.tab-control-item {
  flex: 1;
  text-align: center;
  height: 40px;
  line-height: 40px;
}
.active {
  color: var(--color-tint);
}
.active span {
  border-bottom: 3px solid var(--color-tint);
  padding: 5px;
}
</style>
